package com.atguigu.utils;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch =new CountDownLatch(6);
        for (int i = 0; i < 6; i++) {
            int a = i;
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"\t"+a+"离开教室了");
                countDownLatch.countDown();
            },String.valueOf(i)).start();
        }
        countDownLatch.await();
        System.out.println(Thread.currentThread().getName()+"\t"+"门上锁了");
    }
}
